//填写驳回理由
import React, {Component} from 'react'
import {View, Text, TouchableOpacity, TextInput} from 'react-native'
import styles from '../../configs/styles'

class denyReason extends Component {
  static navigationOptions = ({navigation}) => {
    const { params = {} } = navigation.state
    return {
      title: '驳回理由',
      headerRight: (<TouchableOpacity style={{paddingRight: 10}} onPress={params.handleSave||(()=>null)}>
        <Text style={styles.text_white}>提交</Text>
      </TouchableOpacity>)
    }
  };


  componentDidMount() {
    // We can only set the function after the component has been initialized
    this.props.navigation.setParams({ handleSave: this._submit });
  }

  //初始化props和state
  constructor(props) {
    super(props);
    const params = props.navigation.state.params || {}
    this.state = {
      remark: '',
      call_back: params.call_back
    }
  }

  _submit = ()=>{
    this.state.call_back(this.state.remark)
    this.props.navigation.goBack()
  }


  render() {

    return (
      <View style={{flex: 1}}>
        <TextInput autoCapitalize='none' autoFocus={true}  multiline={true}
                   style={{flex:1, backgroundColor: 'white', height: 300, textAlignVertical: 'top', padding: 20 }} placeholder={'请填写驳回理由'}
                   onChangeText={(v)=>{this.state.remark=v}}/>
      </View>
    )
  }

}

export default denyReason